package com.training.bt.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.training.bt.entity.Post;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface PostMapper extends BaseMapper<Post> {
    List<Post> selectByUserId( Long userId);
    List<Post> selectAllPostsWithCommentCount(); // 添加查询所有帖子及评论数的方法
    // 根据帖子ID查询单个帖子及其评论数
    Post selectPostByIdWithCommentCount(@Param("postId") Long postId);
    
    // 根据用户ID查询该用户的所有帖子及其评论数
    List<Post> selectPostsByUserIdWithCommentCount(@Param("userId") Long userId);
}